{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gs_quant.common import PayReceive, Currency\n",
    "from gs_quant.instrument import IRSwaption\n",
    "from gs_quant.session import Environment, GsSession\n",
    "from gs_quant.risk import MarketDataShockBasedScenario, MarketDataPattern, MarketDataShock, MarketDataShockType"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# external users should substitute their client id and secret; please skip this step if using internal jupyterhub\n",
    "GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('run_analytics',))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "ir_spot_scenario = MarketDataShockBasedScenario(\n",
    "    shocks={MarketDataPattern('IR', 'EUR'): MarketDataShock(MarketDataShockType.Absolute, 50 / 10000)}\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "swaption = IRSwaption(PayReceive.Receive, '5y', Currency.EUR, expiration_date='13m', strike='atm')\n",
    "swaption.resolve()\n",
    "\n",
    "with ir_spot_scenario:\n",
    "    swaption_scenario_price = swaption.price()\n",
    "\n",
    "# Look at the difference between scenario and base prices\n",
    "print('Base price:     {:,.2f}'.format(swaption.price()))\n",
    "print('Scenario price: {:,.2f}'.format(swaption_scenario_price))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
